#pragma once
#include <map>
#include "sstring.h"

class Mapss : public map<string,sstring>
{
public:
	inline bool have(const string& key)const
	{
		return find(key) != end();
	}
	template<typename T>
	inline bool equal(const string& key, T value)const
	{
		const_iterator i = find(key);
		if(i == end())
		{
			return false;
		}
		sstream ss; ss << value;
		return i->second == ss.str();
	}
	inline string str(void)const
	{
		return toString();
	}
	inline string toString(void)const
	{
		int b = 0;
		string s = "\n";

		for(const_iterator i = begin(); i != end(); i++)
		{
			s += (b++ ? "\n\t[" : "\t[");
			s += i->first ;
			s += "]="; 
			s += i->second;;
		}
		return s;
	}
};


class Mapmss : public map<int,Mapss>
{
public:
	inline string toString(void)const
	{
		sstring s;

		for(const_iterator i = begin(); i != end(); i++)
		{
			s += "<";
			s << (i->first >> 16);
			s += ",";
			s << (i->first & 0xffff);
			s += ">={";
			s += i->second.toString();
			s += "}\n";
		}
		return s;
	}
};
